package main

import (
	"encoding/csv"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	ids := getUserID()
	fmt.Printf("uids:%v \n", ids)
}

func getUserID() []int64 {
	fileName := "./recharge.csv"
	fs, err := os.Open(fileName)
	if err != nil {
		log.Printf("file open err: %v\n", err)
	}
	defer fs.Close()

	r := csv.NewReader(fs)
	uids := make([]int64, 0, 0)
	for {
		line, error := r.Read()
		if error == io.EOF {
			break
		} else if error != nil {
			log.Fatal(error)
		}
		userIDStr := line[0]
		userID, err := strconv.ParseInt(userIDStr, 10, 64)
		if err != nil {
			fmt.Println(userIDStr, err)
			return nil
		}
		uids = append(uids, userID)
	}
	return uids
}
